/*
============================================================================
 Name        : Logger.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CLogger implementation
============================================================================
*/

#include "Logger.h"


CLogger::CLogger()
{
}

EXPORT_C CLogger::~CLogger()
{
	iLog.CloseLog();
	iLog.Close();
}

EXPORT_C CLogger* CLogger::NewLC(const TDesC& aFilename)
{
	CLogger* self = new (ELeave)CLogger();
	CleanupStack::PushL(self);
	self->ConstructL(aFilename);
	return self;
}

EXPORT_C CLogger* CLogger::NewL(const TDesC& aFilename)
{
	CLogger* self = CLogger::NewLC(aFilename);
	CleanupStack::Pop(); // self;
	return self;
}

void CLogger::ConstructL(const TDesC& aFilename)
{
	iLog.Connect();
	iLog.CreateLog(_L("iradio"), aFilename, EFileLoggingModeOverwrite);
}

EXPORT_C void CLogger::Write(TDesC& aText)
{
	iLog.Write(aText);
}

EXPORT_C void CLogger::Write(TDesC8& aText)
{
	TBuf<1000> buf;
	buf.Copy(aText);
	buf.SetLength(aText.Length());

	iLog.Write(buf);
}

EXPORT_C void CLogger::WriteFormat(TRefByValue<const TDesC16> aFmt, ...)
{
	iLog.WriteFormat(aFmt);
}